<style>
    .table-adminlog tr td {
        word-break: break-all;
    }
</style>
<table class="table table-striped table-chapterdetail">
    <thead>
    <tr>
        <th style="text-align: center;">{$resourceName}</th>
    </tr>
    </thead>
    <tbody>
        {volist name="resource" id="vo" }
        <tr>
            <td width="90%">
                {if isset($vo.pretations)}　{$vo.pretations}{/if}
                {if isset($vo.sentences)}　{$vo.sentences}{/if}
                {if isset($vo.name)}　{$vo.name}{/if}
                {if isset($vo.start)}　开始：{$vo.start/1000}s{/if}
                {if isset($vo.duration)}　时长：{$vo.duration/1000}s{/if}
            </td>
            <td>
                {if isset($vo.wordPic)}　<a href="javascript:"><img class="img-sm img-center" data-tips-image src="{$resmain}{$vo.wordPic}"></a>{/if}
                {if isset($vo.wordFile)}　<a href="#" onclick="stopall();playAudio('{$resmain}{$vo.wordFile}',0,0);return false;"><i class="fa fa-volume-up"></i></a>{/if}
                {if isset($vo.audioUrl)}　<a href="#" onclick="stopall();playAudio('{$resmain}{$vo.audioUrl}','{$vo.start}','{$vo.duration}');return false;"><i class="fa fa-volume-up"></i></a>{/if}
            </td>
        </tr>
        {/volist}
    </tbody>
</table>
<div class="hide layer-footer">
    <label class="control-label col-xs-12 col-sm-2"></label>
    <div class="col-xs-12 col-sm-8">
        <button type="reset" class="btn btn-primary btn-embossed btn-close" onclick="Layer.closeAll();">{:__('Close')}</button>
    </div>
</div>
<script type="text/javascript">
    function playAudio(value,start,duration){
        var audio = new Audio(value);
        if (start>0||duration>0) {
            audio.load();
            const startTime = start/1000;
            const endTime = start/1000+duration/1000;
            audio.currentTime = startTime;
            audio.addEventListener("timeupdate",() =>{
                const currentTime = audio.currentTime;
                if (currentTime >= endTime) {
                    audio.pause();
                  }
            });
        }
        audio.play();
    }
    function stopall(){
        var audio = new Audio('audio');
        audio.pause();
        
    }
</script>
